<script setup lang="ts">
import {useRouter} from "vue-router";
import TeamCartList from "../../components/TeamCartList.vue";
import {onMounted, ref} from "vue";
import {getUserTeamCreate} from "@/api/user.ts";

// 加入队伍
const router = useRouter()
const doJoinTeam = () => {
  router.push('/team/add')
}
const offset = ref({ x: 300, y: 500 })

// 获取队伍列表
const teamList = ref()
onMounted(() => listTeam())
const searchText = ref('')
const currentPage = ref(1)
const listTeam = async (val='',) => {
  const res = await getUserTeamCreate(val,currentPage.value)
  teamList.value = res.data.data.records
}
const onSearch = () => {
  listTeam(searchText.value)
}

</script>

<template>
  <van-floating-bubble
      axis="lock"
      icon="plus"
      :offset="offset"
      @click="doJoinTeam"
  />
  <div>
    <van-search v-model="searchText" @search="onSearch" placeholder="搜索队伍" />
  </div>
  <div>
    <TeamCartList :team-list="teamList"></TeamCartList>
    <van-empty v-if="!teamList || teamList.length<1" image="search" description="没有相应队伍" />
  </div>
</template>

<style scoped>

</style>